package com.lzc.service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;

import com.baomidou.mybatisplus.service.IService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.lzc.entity.SysUser;
import com.lzc.mapper.SysUserDao;
import com.lzc.util.handle.JsonResp;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Transactional
public class SysUserService extends ServiceImpl<SysUserDao, SysUser> implements IService<SysUser> {

    /**
     * 查询所有会员
     * @return
     */
	public JsonResp findPage() {
		//分页方式一
//		Page<SysUser> sysUserPage = this.selectPage(new Page<>(1, 10), new EntityWrapper<SysUser>().orderBy("create_time", false));
//		return JsonResp.page(sysUserPage);
		//分页方式二
		Wrapper<SysUser> sysUserWrapper = new EntityWrapper<SysUser>().orderBy("create_time", false);
		List<SysUser> sysUsers = baseMapper.selectPage(new Page<>(1, 10), sysUserWrapper);
		Integer total = baseMapper.selectCount(sysUserWrapper);
		return JsonResp.page(1,10,sysUsers,total);
	}
}
